﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.BLL;

namespace Automobile.service.UI
{
    public partial class VIPShow : System.Web.UI.Page
    {
        MemberCardBLL bll = new MemberCardBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                Loadqq();
                Session["count"] = bll.count();
            }
        }

        public void Loadqq()
        {
            this.AspNetPager1.PageSize = 6;
            this.AspNetPager1.RecordCount = bll.Count();
            this.Repeater1.DataSource = bll.ShowMemberCard(6, this.AspNetPager1.CurrentPageIndex);
            this.Repeater1.DataBind();
        }
        protected void AspNetPager1_PageChanged1(object sender, EventArgs e)
        {
            Loadqq();
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string eName = e.CommandName;
            string VipID = e.CommandArgument.ToString();
            switch (eName)
            {
                case "Del":
                    if (bll.Del(Convert.ToInt32(VipID))>0)
                    {
                        Response.Write("<script>alert('删除成功！');</script>");
                        Loadqq();
                    }
                    else
                    {
                        Response.Write("<script>alert('删除失败！');</script>");
                    }
                    break;
                case "Upt":
                    Response.Redirect("VIPEdit.aspx?id=" + VipID);
                    break;
            }
        }

        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            this.AspNetPager1.PageSize = 6;
            this.AspNetPager1.RecordCount = bll.Count();
            this.Repeater1.DataSource = bll.ShowMemberCard_Sel(6, this.AspNetPager1.CurrentPageIndex, this.MemberCard_owner.Value, this.MemberCard_Name.Value);
            this.Repeater1.DataBind();
        }
    }
}